#--
# Project:	pkgman
# File:		pkgman/Rakefile
# Revision:	$Id: Rakefile 270 2007-12-16 02:40:02Z someword $
# Home:         http://code.google.com/p/pkgman/
# Author:	Derek Olsen <someword at gmail dot com>
# Copyright:	(c) 2007 by Derek Olsen
# License:	GNU General Public License v2 
#++

require 'rake/rdoctask'
 
# Define the usage message which will be displayed when rake is run with
# no arguments.
usage = <<_EOF

 The default task prints this usage.
 
 The other available tasks and their functions are
 rdoc    - Create the ruby rdoc documentation.
 dryrun  - Report what actions would be taken but dont do anything.
 pkgman  - Execute pkgman and perform the required package actions.
 mkpkg   - Create an solaris pkgman pkg
 t_up    - Run the package upgrade unit test
 t_mir   - Test the multiple install and remove
 t_key   - Test key checking logic 
_EOF

#
# File sets
#
PKGMAN_FILES   = FileList['bin/pkgman.rb']

#
# Documentation
#

desc "Generate rdoc documents for pkgman."
Rake::RDocTask.new(:rdoc) do |rdoc|
  rdoc.rdoc_dir = 'docs'
  rdoc.title    = 'pkgman'
  rdoc.options << '--line-numbers' << '--inline-source'
  rdoc.rdoc_files = PKGMAN_FILES 
end


# Define the config file name
conf = "pkgman.yaml"

# Define the default task
desc "Pring usage"

task :default do
  puts usage
end


# Alias the help taks to default
desc "Pring usage"
task :help => :default

# Make an pkgman pkg
task :mkpkg do
 system("./test/make_pkgman_pkg.rb")
end

# Perform the package upgrade test
task :t_up do
  Dir.chdir("test")
  system "./test_upgrade_prep.rb"
  system "./test_pkgman.rb -f pkg_prototypes/pkg_upgrade.yaml -- --name test_package_upgrade"
end

# Perform the multiple install and remove test
task :t_mir do
  Dir.chdir("test")
  system "./test_multiple_prep.rb"
  system "./test_pkgman.rb -f pkg_prototypes/pkg_install_and_remove.yaml -- --name test_multiple_install_and_remove"
end

# Perform the key checking verification tests
task :t_key do
  Dir.chdir("test")
  system "./test_pkgman.rb -f pkg_prototypes/missing_keys.yaml -- --name=/missing_key/" 
end
